import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** CRM 产品物料关联信息 */
export interface ProductComponents {
          id: number; // 编号，主键自增
          componentsId: number; // 所属物料id
          productId: number; // 所属产品id
          count?: number; // 数量
          remark: string; // 备注
  }

// CRM 产品物料关联 API
export const ProductComponentsApi = {
  // 查询CRM 产品物料关联分页
  getProductComponentsPage: async (params: any) => {
    return await request.get({ url: `/crm/product-components/page`, params })
  },

  // 查询CRM 产品物料关联详情
  getProductComponents: async (id: number) => {
    return await request.get({ url: `/crm/product-components/get?id=` + id })
  },

  // 新增CRM 产品物料关联
  createProductComponents: async (data: ProductComponents) => {
    return await request.post({ url: `/crm/product-components/create`, data })
  },

  // 修改CRM 产品物料关联
  updateProductComponents: async (data: ProductComponents) => {
    return await request.put({ url: `/crm/product-components/update`, data })
  },

  // 删除CRM 产品物料关联
  deleteProductComponents: async (id: number) => {
    return await request.delete({ url: `/crm/product-components/delete?id=` + id })
  },

  /** 批量删除CRM 产品物料关联 */
  deleteProductComponentsList: async (ids: number[]) => {
    return await request.delete({ url: `/crm/product-components/delete-list?ids=${ids.join(',')}` })
  },

  // 导出CRM 产品物料关联 Excel
  exportProductComponents: async (params) => {
    return await request.download({ url: `/crm/product-components/export-excel`, params })
  },
}